#ifndef __MEDIA_SERIAL_PROTOCOL_H__
#define __MEDIA_SERIAL_PROTOCOL_H__

#include <map>
#include <mutex>
#include <string>
#include <functional>
#include "Thread/Thread.h"
#include "Poller/Timer.h"
#include "Comm.h"



namespace Media{


class mediaSerialProtocol{

public:
    const std::string KvmSendTxet = "KVM OK";

    enum
    {
        PORT_PRINT = 0,
        PORT_KVM
    };
public:    
	static mediaSerialProtocol *instance();

	bool serialProtocolInit(void);

	bool serialTestKvm();
	
private:
	mediaSerialProtocol();

	bool serialSetAttribute(CommPort*          pCommPort, CommAttribute attr);

	bool serialPortWrite(void* buf, ulong len, int port);

	void ThreadProc(Fdt::Thread *thread);

	bool serialPortRead(void* buf, ulong len, int port);

private:
	static mediaSerialProtocol *            sm_instance;

	static std::mutex 			            sm_insMutex;

	CommPort *                              m_pCommPortKvm;

	Fdt::Thread 						    m_thread{"mediaSerialProtocol"};//thread放在最后,保证thread最后构造,最先析构

};

}//namespace Media
#endif




